
/**
 * @description 导航栏高度
 */

export const customNavbarHeight = 40;
/**
 *
 * 获取枚举值：FUNTION_FLAG.TTT
 * 获取枚举描述：FUNTION_FLAG.getDesc('SH')
 * 通过枚举值获取描述：FUNTION_FLAG.getDescFromValue('TG')
 *  @description  表单类型标识
 */
export const FORM_FLAG = createEnum({
  SKIP: ["skip", "页面跳转"],
  TITLE: ["title", "标题"],
  INPUT: ["input", "普通inpput框"],
  SELECT: ["select", "选择下拉框"],
  SLOT: ["slot", "插槽"],
  SELECT_CUSTOM: ["select-custom", "自定义下拉框"],
  DATE: ["date", "时间选择器"],
  DATE_CUSTOM: ["date_custom", "自定义时间选择器"],
  DATA_PICKER: ["data_picker", "多级联动"]
})

/**
 * @description 表单使用的类型
 */
export const FORM_TYPE = createEnum({
  ADD: ["add", "新增"],
  EDIT: ["edit", "编辑"],
  SEARCH: ["search", "查询"]
})

/**
 * @description 表格加载标识
 */

export const TABLE_DATA_LOADING_FLAG = createEnum({
  LOADING: [1, "加载中"],
  MORE: [2, "加载完成有数据"],
  NO_MORE: [3, "加载完成没有数据"],
})

/**
 * @description 常用标识
 */
export const BASIC_FLAG = createEnum({
  ADD: ["10", "新增跳转"],
  EDIT: ["20", "编辑跳转"],
  PARTICULAR: ["30", "详情页跳转"],
  DETAIL: ["31", "明细页跳转"],
  REMOVE: ["40", "删除"],
  BATCH_REMOVE: ["41", "批量删除"],
  SUBMIT: ["50", "提交"],
  ENABLE: ["60", "启用"],
  DISABLE: ["70", "禁用"],
  START: ["80", "开始"],
  END: ["88", "结束"],
  SELECT: ["90", "选择页面跳转"],
})

function createEnum(definition) {
  const valueMap = {}
  const descMap = {}
  for (const key of Object.keys(definition)) {
    const [value, desc] = definition[key]
    valueMap[key] = value
    descMap[value] = desc
  }
  return {
    ...valueMap,
    getDesc(key) {
      return (definition[key] && definition[key][1]) || "无"
    },
    getDescFromValue(value) {
      return descMap[value] || "无"
    }
  }
}

